/** @defgroup U-blox Gsm modem
 * @{
 */
/*
 * Application\Inc\gsm_modem.h
 *
 *
 * Author: rex huang
 * Copyright (c) 2010 rex huang
 * All rights reserved.
 *
 * Modifications:
 */

#ifndef __GSM_MODEM_H_
#define __GSM_MODEM_H_

#ifdef  __cplusplus
extern "C" {
#endif		/* __cplusplus */

#include "Queue.h"
#define GSM_STR_RESP_DTAT_LEN	(16)
#define GSM_SENDSTR_LEN			(256)

//Support to GPRS_U_BLOX
#define TELPHONE_NO	"0937711784" 
#define SMS_SEND_TIME	(60) 

#define MAX_LEN_PHONE_NO	(30)



typedef struct _Gsm_SendString {
	unsigned short pre_delay;			///< delay ms before the send AT_String
	unsigned short dataLen;				
//	char *p_bufData;
	unsigned short end_delay;			///< delay ms ending the send AT_String
	char respond_data[GSM_STR_RESP_DTAT_LEN];				///< Check respond data , Null string is mean Do not check , Byte[7] always is 0
	unsigned short respond_WaitTimeOut;	///< delay ms wait respond from GMS
}Gsm_SendString;



extern QBuf gGSM_TxQBuf;
extern QBuf gGSM_RxQBuf;
extern QBuf gGSM_Q_SendStringIdx;

extern QBuf gGsm_Q_StringBuf;
extern char gGsm_RespChk[GSM_STR_RESP_DTAT_LEN];
extern char gGsm_RespChk_Sts;


void GSM_PW_ON(void);	//fenris 20110607 test
void GSM_PW_OFF(void);	//fenris 20110607 test

void GSM_Init(void);

void Gsm_Ini_Task(void);
void Gsm_Task(void);



void GSM_UART_IRQ_Tx(void);
void GSM_UART_IRQ_Rx(void);
unsigned short GsmUart_Read(char *buf, unsigned short count);
void GsmUart_Write(char *buf, unsigned short count);


void GsmUart_Send(char *buf);
void GsmUart_AT_CMGS(char *telNo,char *msg);
unsigned char GsmUart_Display(char *buf);

char qGsm_Send(char *bufData,unsigned short pre_dly,unsigned short b_Len,unsigned short end_dly,char *rspData,unsigned short repWait);
char qGsm_AtCmd(char *bufData,unsigned short pre_dly,unsigned short end_dly,char *rspData,unsigned short repWait);

#ifdef __cplusplus
}
#endif	/* __cplusplus */
#endif	/* #ifndef __GSM_MODEM_H_ */
/** @} */